xenstored: Remove unused util code.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 1 Aug 2007 11:05:42 +0000 (12:05 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 1 Aug 2007 11:05:42 +0000 (12:05 +0100)
Signed-off-by: Keir Fraser <keir@xensource.com>
tools/xenstore/utils.c
tools/xenstore/utils.h

index 16f87cdc05b07da311aa020f58193dedf4178ec7..45e71efd14c271ec090a0e18c2ad3195da9e6099 100644 (file)
@@ -61,72 +61,3 @@ void barf_perror(const char *fmt, ...)
        }
        exit(1);
 }
-
-void *_realloc_array(void *ptr, size_t size, size_t num)
-{
-       if (num >= SIZE_MAX/size)
-               return NULL;
-       return realloc_nofail(ptr, size * num);
-}
-
-void *realloc_nofail(void *ptr, size_t size)
-{
-       ptr = realloc(ptr, size);
-       if (ptr)
-               return ptr;
-       barf("realloc of %zu failed", size);
-}
-
-void *malloc_nofail(size_t size)
-{
-       void *ptr = malloc(size);
-       if (ptr)
-               return ptr;
-       barf("malloc of %zu failed", size);
-}
-
-/* This version adds one byte (for nul term) */
-void *grab_file(const char *filename, unsigned long *size)
-{
-       unsigned int max = 16384;
-       int ret, fd;
-       void *buffer;
-
-       if (streq(filename, "-"))
-               fd = dup(STDIN_FILENO);
-       else
-               fd = open(filename, O_RDONLY, 0);
-
-       if (fd == -1)
-               return NULL;
-
-       buffer = malloc(max+1);
-       if (!buffer)
-               goto error;
-       *size = 0;
-       while ((ret = read(fd, buffer + *size, max - *size)) > 0) {
-               *size += ret;
-               if (*size == max) {
-                       void *nbuffer;
-                       max *= 2;
-                       nbuffer = realloc(buffer, max + 1);
-                       if (!nbuffer)
-                               goto error;
-                       buffer = nbuffer;
-               }
-       }
-       if (ret < 0)
-               goto error;
-       ((char *)buffer)[*size] = '\0';
-       close(fd);
-       return buffer;
-error:
-       free(buffer);
-       close(fd);
-       return NULL;
-}
-
-void release_file(void *data, unsigned long size __attribute__((unused)))
-{
-       free(data);
-}
index df82c1c5ef7da78ec62fe8de7cce3e174b04a5ec..ce14f3a408b1f85f294f123ec3ca194f1ecaa26d 100644 (file)
@@ -21,39 +21,12 @@ static inline bool strends(const char *a, const char *b)
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
-#define ___stringify(x)        #x
-#define __stringify(x)         ___stringify(x)
-
-/* Convenient wrappers for malloc and realloc.  Use them. */
-#define new(type) ((type *)malloc_nofail(sizeof(type)))
-#define new_array(type, num) realloc_array((type *)0, (num))
-#define realloc_array(ptr, num) ((__typeof__(ptr))_realloc_array((ptr), sizeof((*ptr)), (num)))
-
-void *malloc_nofail(size_t size);
-void *realloc_nofail(void *ptr, size_t size);
-void *_realloc_array(void *ptr, size_t size, size_t num);
-
 void barf(const char *fmt, ...) __attribute__((noreturn));
 void barf_perror(const char *fmt, ...) __attribute__((noreturn));
 
-/* This version adds one byte (for nul term) */
-void *grab_file(const char *filename, unsigned long *size);
-void release_file(void *data, unsigned long size);
-
-/* Signal handling: returns fd to listen on. */
-int signal_to_fd(int signal);
-void close_signal(int fd);
-
 void xprintf(const char *fmt, ...);
 
 #define eprintf(_fmt, _args...) xprintf("[ERR] %s" _fmt, __FUNCTION__, ##_args)
-#define iprintf(_fmt, _args...) xprintf("[INF] %s" _fmt, __FUNCTION__, ##_args)
-
-#ifdef DEBUG
-#define dprintf(_fmt, _args...) xprintf("[DBG] %s" _fmt, __FUNCTION__, ##_args)
-#else
-#define dprintf(_fmt, _args...) ((void)0)
-#endif
 
 /*
  * Mux errno values onto returned pointers.